﻿using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using IterationLife.Domains.Sports.Enums;
using Util.Domains;
using Util.Domains.Auditing;

namespace IterationLife.Domains.Sports.Models {
    /// <summary>
    /// SportUsers
    /// </summary>
    [Description( "SportUsers" )]
    public partial class SportUser : AggregateRoot<SportUser>,IDelete,IAudited {
        /// <summary>
        /// 初始化SportUsers
        /// </summary>
        public SportUser() : this( Guid.Empty ) {
        }

        /// <summary>
        /// 初始化SportUsers
        /// </summary>
        /// <param name="id">SportUsers标识</param>
        public SportUser( Guid id ) : base( id ) {
        }

        /// <summary>
        /// 合作方用户Id
        /// </summary>
        [Required(ErrorMessage = "合作方用户Id不能为空")]
        [StringLength( 200, ErrorMessage = "合作方用户Id输入过长，不能超过200位" )]
        public string PartnerUserId { get; set; }
        /// <summary>
        /// 身份标示
        /// </summary>
        [StringLength( 500, ErrorMessage = "身份标示输入过长，不能超过500位" )]
        public string Token { get; set; }
        /// <summary>
        /// 手机号
        /// </summary>
        [StringLength( 50, ErrorMessage = "手机号输入过长，不能超过50位" )]
        public string Mobile { get; set; }
        /// <summary>
        /// 头像
        /// </summary>
        [StringLength( 500, ErrorMessage = "头像输入过长，不能超过500位")]
        public string Photo { get; set; }
        /// <summary>
        /// 设备
        /// </summary>
        [Required(ErrorMessage = "设备不能为空")]
        public EquipmentType EquipmentType { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTime { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public Guid? CreatorId { get; set; }
        /// <summary>
        /// 最后修改时间
        /// </summary>
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 最后修改人
        /// </summary>
        public Guid? LastModifierId { get; set; }
        /// <summary>
        /// 是否删除
        /// </summary>
        [Required(ErrorMessage = "是否删除不能为空")]
        public bool IsDeleted { get; set; }
        
        /// <summary>
        /// 运动员
        /// </summary>
        public virtual SportAthlete SportAthlete { get; set; }

        /// <summary>
        /// 添加描述
        /// </summary>
        protected override void AddDescriptions() {
            AddDescription( "体育用户编号", Id );
            AddDescription( "合作方用户Id", PartnerUserId );
            AddDescription( "身份标示", Token );
            AddDescription( "手机号", Mobile );
            AddDescription( "头像", Photo );
            AddDescription( "设备", EquipmentType );
            AddDescription( "创建时间", CreationTime );
            AddDescription( "创建人", CreatorId );
            AddDescription( "最后修改时间", LastModificationTime );
            AddDescription( "最后修改人", LastModifierId );
        }
        
        /// <summary>
        /// 添加变更列表
        /// </summary>
        protected override void AddChanges( SportUser newEntity ) {
            AddChange( "Id", "体育用户编号", Id, newEntity.Id );            
            AddChange( "PartnerUserId", "合作方用户Id", PartnerUserId, newEntity.PartnerUserId );
            AddChange( "Token", "身份标示", Token, newEntity.Token );
            AddChange( "Mobile", "手机号", Mobile, newEntity.Mobile );
            AddChange("Photo", "头像", Photo, newEntity.Photo );
            AddChange( "EquipmentType", "设备", EquipmentType, newEntity.EquipmentType );
            AddChange( "CreationTime", "创建时间", CreationTime, newEntity.CreationTime );
            AddChange( "CreatorId", "创建人", CreatorId, newEntity.CreatorId );
            AddChange( "LastModificationTime", "最后修改时间", LastModificationTime, newEntity.LastModificationTime );
            AddChange( "LastModifierId", "最后修改人", LastModifierId, newEntity.LastModifierId );
        }
    }
}